﻿using System;
using System.Collections.Generic;
using System.Text;

namespace AttributeDemo
{
    /// <summary>
    ///  特性应用的位置
    ///  AttributeTargets  特性使用位置
    ///  AllowMultiple  是否可以重复标记
    /// </summary>

    [AttributeUsage(AttributeTargets.All,AllowMultiple =true)]
    public class ZiDingYiAttribute : Attribute
    {
        public ZiDingYiAttribute()
        {
            Console.WriteLine("无参数的构造函数");
        }
        public ZiDingYiAttribute(int i)
        {
            Console.WriteLine("Int类型构造函数");
        }
        public ZiDingYiAttribute(string str)
        {
            Console.WriteLine("String类型构造函数");
        }
        public ZiDingYiAttribute(int i,string str)
        {
            Index = i;
            Summary = str;
            Console.WriteLine("Int&String类型构造函数");
        }

        public int Index { get; private set; }
        public string Summary { get; private set; }
        public void Show()
        {
            Console.WriteLine("通过反射调用特性");
            Console.WriteLine($"Index={Index}");
            Console.WriteLine($"Summary={Summary}");
        }
    }

    [AttributeUsage(AttributeTargets.All, AllowMultiple = true,Inherited =true)]
    public class ZiDingYiChildAttribute : ZiDingYiAttribute
    {
        //public ZiDingYiChildAttribute() : base()
        //{ 
        //}
    }
}
